/*************************************************************************
	> File Name: bridge.h
	> Author: ma6174
	> Mail: ma6174@163.com 
	> Created Time: 2021年12月07日 星期二 22时41分30秒
 ************************************************************************/

#include<iostream>
#include <string>

struct Implementor
{
	virtual void op() = 0;
};

struct ConcreteImplementorA : public Implementor
{
	virtual void op()
	{
		std::cout << "具体实现A的方法执行" << std::endl;
	}
};

struct ConcreteImplementorB : public Implementor
{
	virtual void op()
	{
		std::cout << "具体实现B的方法执行" << std::endl;
	}
};

class Abstraction
{
public:
	void setImplementor(Implementor* im)
	{
		if (implementor != nullptr)
			delete implementor;
		this->implementor = im;
	}

	virtual ~Abstraction()
	{
		delete implementor;
	}

	virtual void op() = 0;

protected:
	Implementor* implementor;
};

class RefineAbstraction : public Abstraction
{
public:
	virtual void op()
	{
		implementor->op();
	}
};
